const app = getApp();
let WxParse = require("../../component/common/wxparse/wxparse");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    theme:app.theme,
    goods:app.data.productDetail,
    tipscurentDot:0,
    isPlay:false,
    time: 0,
    timeData: {},
   
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: this.data.goods.title
    })
    this.setData({
      time:app.functions.OffGroup()
    })
    WxParse.wxParse('article', 'html', this.data.goods.description, this);
  },
  OnShowShare(e){
    this.setData({
      shareShow:true
    })
  },
  onChange(e) {
    if (e.detail.hours >= 1 && e.detail.hours <= 9) {
      e.detail.hours  = "0" + e.detail.hours;
    }
    if (e.detail.minutes >= 0 && e.detail.minutes <= 9) {
      e.detail.minutes  = "0" + e.detail.minutes;
    }	
    if (e.detail.seconds >= 0 && e.detail.seconds <= 9) {
      e.detail.seconds  = "0" + e.detail.seconds;
    }	
    this.setData({
      timeData: e.detail
    });
  },
  tipscurent(e){
    let index = e.currentTarget.dataset.index;
    this.setData({
      tipscurentDot:index
    })
  },
  tipscurentChange(e){
    let index = e.detail.current;
    this.setData({
      tipscurentDot:index,
      isPlay:false
    })
  },
  playVideo(){
    this.data.videoContext = wx.createVideoContext('myVideo');
    this.setData({
      isautoplay:true,
      isPlay:true
    })
    this.data.videoContext.play();
  },
  stopVideo(){
    this.setData({
      isPlay: false
    })
    this.data.videoContext.play();
  },
  endPlay(e){
    this.setData({
      isPlay:false
    })
  },
  // 弹出规格
  toSukDetail(){
    this.selectComponent("#suk").getProductsDetail(this.data.goods.id,0);
  },
  // 去购物车
  toCart(){
    wx.switchTab({
      url: '/pages/cart/cart'
    });
  },
  // 加入购物车
  getCart(){

  },
  // 立即购买
  getBuy(){

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function(){
    let share = {};
      share = {
        title: this.data.goods.specTitle,
        path: '/pages/detail/detail?shopid=1&shareid=1',
        imageUrl: this.data.goods.thumbSquare
      };
    return share;
  },
  // 生成海报
  OnShare(){
      console.info("生成海报!");
      this.selectComponent("#share").ProductShare(this.data.goods);
  }
})